'use strict'

// <--    还原前    -->
var _0x4692f3 = {};

_0x4692f3[_0x46b8('0x89e')] = function(_0x4e1e7c, _0xd66178) {
    return _0x4e1e7c(_0xd66178);
},

_0x4692f3[_0x46b8('0x142')] = function(_0x2f2063, _0x25600f) {
    return _0x2f2063 > _0x25600f;
},

_0x4692f3[_0x46b8('0x872')] = _0x46b8('0x6cc'),
_0x4692f3[_0x46b8('0x49b')] = function(_0x161ed8, _0x10c423) {
    return _0x161ed8 > _0x10c423;
};

/**
 * <--    特点    -->
 * 一个语句中包含多个普通表达式（非VariableDeclaration等语句），可以直接拆分成多个语句，方便阅读
 * 
 * <--    解决办法    -->
 * 找到表达式，直接构造新的语句，删除老语句
 * 
 * <--    冗余判断    -->
 * SequenceExpression.parentPath == t.ExpressionStatement
 * 
 **/

// <--    还原后    -->
var _0x4692f3 = {};

_0x4692f3[_0x46b8('0x89e')] = function (_0x4e1e7c, _0xd66178) {
  return _0x4e1e7c(_0xd66178);
};

_0x4692f3[_0x46b8('0x142')] = function (_0x2f2063, _0x25600f) {
  return _0x2f2063 > _0x25600f;
};

_0x4692f3[_0x46b8('0x872')] = _0x46b8('0x6cc');

_0x4692f3[_0x46b8('0x49b')] = function (_0x161ed8, _0x10c423) {
  return _0x161ed8 > _0x10c423;
};
// <----------------->


const {parse} = require('@babel/parser');
const traverse = require('@babel/traverse').default;
const t = require('@babel/types');
const generator = require('@babel/generator').default;

let xcode = `var _0x4692f3 = {};

_0x4692f3[_0x46b8('0x89e')] = function(_0x4e1e7c, _0xd66178) {
    return _0x4e1e7c(_0xd66178);
},

_0x4692f3[_0x46b8('0x142')] = function(_0x2f2063, _0x25600f) {
    return _0x2f2063 > _0x25600f;
},

_0x4692f3[_0x46b8('0x872')] = _0x46b8('0x6cc'),
_0x4692f3[_0x46b8('0x49b')] = function(_0x161ed8, _0x10c423) {
    return _0x161ed8 > _0x10c423;
};`;

const visitor = {
    SequenceExpression:{
        enter:function(path){
            if (!t.isExpressionStatement(path.parent)){
                return;
            }

            let selfStmt = path.parentPath;

            for (let expression of path.get('expressions')){
                selfStmt.insertBefore(t.expressionStatement(expression.node));
            }

            path.remove();
            path.scope.crawl();
        },
    },
}

let ast = parse(xcode);
traverse(ast, visitor);
let {code} = generator(ast);
console.log(code);
